<template>
	<view>
		<view class="distribution_middle_box" v-if="distributorList.length !== 0">
			<!-- top -->
			<view class="detail_top_box">
				<view class="top_total_box">
					总计<span class="top_total_num">{{countAll}}</span><span class="top_total_unit">(单)</span>
				</view>
			</view>
			<view class="middle_con_box">
				<view class="middle_con_all" v-for="(item, index) in distributorList" :key="index">
					<!-- <view class="">
						<view class="avatar_box" v-if="item.avatar">
							<image :src="item.avatar" mode="" class="avatar_img"></image>
						</view>
						<view class="avatar_box" v-else>
							{{item.username.charAt(0)}}
						</view>
					</view> -->

					<view class="user_msg_box">
						<view class="user_name_box">
							<view class="user_name">
								{{item.name}}
							</view>
							<view class="user_level">
								<span v-if="item.level == 1">高级分销员</span>
								<span v-else-if="item.level == 2">中级分销员</span>
								<span v-else-if="item.level == 3">初级分销员</span>
							</view>
						</view>
						<view class="user_phone_box">
							<view class="user_phone">
								手机号：{{item.phone}}
							</view>
							<view class="user_pid">
								PID：{{item.pid}}
							</view>
						</view>
						<view class="user_data">
							加入时间：{{item.created_at}}
						</view>
					</view>

					<!-- <view class="" style="display: flex;">
						<view class="left_avatar_box" v-if="item.avatar">
							<image :src="item.avatar" mode="" class="left_avatar"></image>
						</view>
						<view class="left_avatar_name_box" v-else>
							{{item.username.charAt(0)}}
						</view>
						<view class="" style="width: 85%;">
							<view class="left_box" style="display: flex; justify-content: space-between;">
								<view class="left_title">
									用户名：{{ item.username }}
								</view>
								<view style="color: red;">
									<span v-if="item.level == 1">高级分销员</span>
									<span v-else-if="item.level == 2">中级分销员</span>
									<span v-else-if="item.level == 3">初级分销员</span>
								</view>
							</view>
							<view class="left_box">
								<view class="left_title" style="padding: 10rpx 0;">
									手机号：{{item.phone}}
								</view>
							</view>
							<view class="right_box">
								加入时间： {{ item.created_at }}
							</view>
						</view>
					</view> -->
				</view>
			</view>
		</view>

		<view class="no_data" v-else>
			----- 暂无分销数据 -----
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				distributorList: [],
				dataType: '',
				countAll: '',
				pageObj: {
					pageNow: 1,
					pageSize: 10
				},
				total: 0
			}
		},
		onLoad(option) {
			this.dataType = option.type
			this.countAll = option.countAll
			this.getFxuserDataCount()
		},
		onReachBottom() {
			if (this.pageObj.pageNow < this.total) {
				this.pageObj.pageNow++
				// this.getFxuserDataCountTest()
				this.getFxuserDataCount()
			} else if (this.pageObj.pageNow == this.total) {
				uni.showToast({
					title: '暂无更多数据',
					icon: 'none'
				})
				return
			}
		},
		methods: {
			// 数据统计接口
			getFxuserDataCount() {
				this.$request('/api/getFxuserDataCount', {
					type: this.dataType,
					page_now: this.pageObj.pageNow,
					page_size: this.pageObj.pageSize
				}, 'GET').then(res => {
					if (res.code == 1) {
						this.distributorList = res.data
					} else {
						uni.showToast({
							title: res.msg,
							icon: 'none'
						})
						return
					}
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.distribution_middle_box {
		width: 100%;
		padding: 20rpx 20rpx 0;

		.detail_top_box {
			display: flex;
			justify-content: center;
			background: #FFFFFF;
			border-radius: 8rpx;
			padding: 32rpx 0 34rpx;
			margin-bottom: 14rpx;

			.top_total_box {
				font-family: all-font;
				font-weight: 400;
				font-size: 20rpx;
				color: #333333;

				.top_total_num {
					font-family: my-font;
					font-weight: bold;
					font-size: 58rpx;
					color: #333333;
				}

				.top_total_unit {
					font-size: 24rpx;
				}
			}

			.top_compare_box {
				display: flex;
				align-items: center;
				height: 31rpx;
				background: #F2F2F2;
				border-radius: 15rpx;
				padding: 0 18rpx;

				.top_compare_yesterday {
					font-family: Source Han Sans CN;
					font-weight: 400;
					font-size: 20rpx;
					color: #808080;
					padding: 0 8rpx;

					.top_compare_num {
						font-family: Source Han Sans CN;
						font-weight: 400;
						font-size: 21rpx;
						color: #00C580;
					}
				}

				.top_compare_down {
					width: 0;
					height: 0;
					border-left: 10rpx solid transparent;
					border-right: 10rpx solid transparent;
					border-top: 10rpx solid #00C580;
				}

				.top_compare_up {
					width: 0;
					height: 0;
					border-top: 0 solid transparent;
					border-right: 10rpx solid transparent;
					border-left: 10rpx solid transparent;
					border-bottom: 10rpx solid #FF2B2B;
				}
			}
		}

		.middle_tab_box {
			display: flex;
			align-items: center;
			justify-content: space-between;
			padding: 0 26rpx 0 46rpx;
			margin-bottom: 14rpx;

			.middle_tab_all {
				font-size: 28rpx;
				font-weight: 400;
				color: #333;
				font-family: my-font;

				.tab_bottom {
					width: 36rpx;
					height: 6rpx;
					border-radius: 18rpx;
					background: transparent;
					margin-top: 16rpx;
				}
			}

			.middle_tab_all_active {
				display: flex;
				flex-direction: column;
				align-items: center;
				font-size: 28rpx;
				font-weight: 500;
				color: #4F96FF;
				font-family: my-font;

				.tab_bottom {
					width: 36rpx;
					height: 6rpx;
					border-radius: 18rpx;
					background: #4F96FF;
					margin-top: 16rpx;
				}
			}
		}

		.middle_con_box {
			border-radius: 8rpx;
			background: #FFFFFF;
			margin-top: 14rpx;

			.middle_con_all {
				background: #FFFFFF;
				box-shadow: 0px 8rpx 12rpx 1px #F4F4F4;
				border-radius: 12rpx;
				padding: 33rpx 0 18rpx 25rpx;

				.avatar_box {
					width: 82rpx;
					height: 82rpx;

					.avatar_img {
						width: 100%;
						height: 100%;
					}
				}

				.user_msg_box {

					.user_name_box {
						display: flex;
						align-items: center;

						.user_name {
							font-family: all-font;
							font-weight: 500;
							font-size: 28rpx;
							color: #333333;
							padding-right: 21rpx;
						}

						.user_level {
							display: flex;
							justify-content: center;
							align-items: center;
							width: 133rpx;
							height: 30rpx;
							background: linear-gradient(181deg, #F57957, #FF1B51);
							border-radius: 15rpx;
							font-family: all-font;
							font-weight: 400;
							font-size: 22rpx;
							color: #FFFFFF;
						}
					}

					.user_phone_box {
						display: flex;
						padding: 23rpx 0 41rpx;

						.user_phone {
							font-family: my-font;
							font-weight: 400;
							font-size: 26rpx;
							color: #666666;
							padding-right: 26rpx;
						}

						.user_pid {
							font-family: my-font;
							font-weight: 400;
							font-size: 26rpx;
							color: #666666;
						}
					}

					.user_data {
						font-family: my-font;
						font-weight: 400;
						font-size: 24rpx;
						color: #808080;
					}
				}
			}
		}
	}

	.no_data {
		color: #ccc;
		font-size: 40rpx;
		font-family: all-font;
		text-align: center;
		padding: 50rpx 0;
	}
</style>